<?php
	

autoLoader();
// display( $_REQUEST );
// display( $_POST ); exit;

if( false == isset( $_POST['Submit'] ) || false == valStr( $_POST['name'] ) ) { 
	$str = '';
	$str .= '<form name=myform method=post action=modules.php?file=specialization&mid=' . $_REQUEST['mid'] . '&smid=' . $_REQUEST['smid'] . '>';
	$str .= '<script language=JavaScript>document.myform.submit();</script></form>';
	echo $str;
	exit;
}

if( true == isset( $_POST['operation'] ) && 'insert' == strtolower( $_POST['operation'] ) ) {
	
	$objSpecilization 	= new BaseSpecilizations();
	
	$objSpecilization->setName( $_POST['name'] );
	$objSpecilization->setDescription( $_POST['description'] );
	$objSpecilization->setIsPublished( $_POST['is_published'] );
	$objSpecilization->setOrderNumber( $_POST['OrderNumber'] );
	
	if( 1 == $objSpecilization->insert() ) {
		$str = '';
		$str .= '<form name=myform method=post action=modules.php?file=view_specialization&type=view&mid=' . $_REQUEST['mid'] . '&smid=' . $_REQUEST['smid'] . '>';
		$str .= '<script language=JavaScript>document.myform.submit();</script></form>';
		echo $str;
		exit;
	}
} else if( true == isset( $_POST['operation'] ) && 'update' == strtolower( $_POST['operation'] ) ) {
	$objSpecilizations 	= new Specilizations();
	$objSpecilization 	= $objSpecilizations->fetchDepartmentTypesById( $_POST['Specialization_id'] );
	
	$objSpecilization->setId( $_POST['Specialization_id'] );
	
	if( true == valStr( $_POST['name'] ) ) {
		$objSpecilization->setName( $_POST['name'] );
	}
	
	if( true == valStr( $_POST['description'] ) ) {
		$objSpecilization->setDescription( $_POST['description'] );
	}
		
	if( true == valStr( $_POST['is_published'] ) ) {
		$objSpecilization->setIsPublished( $_POST['is_published'] );
	}
	if( true == valStr( $_POST['OrderNumber'] ) ) {
		$objSpecilization->setOrderNumber( $_POST['OrderNumber'] );
	}
	
	
	if( 1 == $objSpecilization->update() ) {
		$str = '';
		$str .= '<form name=myform method=post action=modules.php?file=view_specialization&type=view&mid=' . $_REQUEST['mid'] . '&smid=' . $_REQUEST['smid'] . '>';
		$str .= '<script language=JavaScript>document.myform.submit();</script></form>';
		echo $str;
		exit;
	}
}

?>